<template >
<div class="mainDiv">
  <div style="display:block;width:100%;min-height:900px;background: url(../../static/images/star-bg.svg) no-repeat;background-size: 100%;" >
    <div class="div0">
      <br><br><br><br><br><br>
      <h1>The new native</h1>
    </div>

<!--    <el-card class="box-card" style="">-->
    <div class="div1" >
    <template>
      <el-table

        :data="tableData"
        @cell-click = "cellClick"
        style="width: 100% ;">
        <el-table-column
          cell-style="font-weight: 700"
          prop="Data"
          label="时间"
          width="180">
        </el-table-column>
        <el-table-column
          prop=Title
          label="题目"
          width="180">
        </el-table-column>
        <el-table-column
          prop="Language"
          label="标签">
        </el-table-column>
      </el-table>
    </template>
      <br>
      <br>
      <div class="block">
<!--        <span class="demonstration">直接前往</span>-->
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"

          :current-page.sync="currentPage3"
          :page-size="10"
          layout="prev, pager, next, jumper"
          :total="1000">
        </el-pagination>
      </div>
      <br>
      <br>
    </div>
<!--    </el-card>-->
  </div>
</div>
</template>

<script>
  import Vue from 'vue' //注意，要在这个页面中引入vue，不然下面的Vue.prototype会报错
    export default {
        name: "Inspiration",
      data(){
        return{
            showDate : "",
            tableData:[],
        }
      },
     mounted:function () {
       this.init()
     },
      methods: {
        init(){
          let that = this;
          let formData = new FormData();
          formData.append("test","0");
          /*that.axios({
            url: '/api/initVue',
            method: 'post',
            data: formData,

          }).then(function (response) {
            if(response.status  === 200 ){
              let m12 = response.data.m12status;
              console.log("初始化",m12);
              if( m12 === 403) {
                that.$router.push({path: '/login'});
              }
            }
          });*/ //如果需要验证才可以访问火箭数据请使用这段代码
          that.axios({
            url: "/api/mongoFind",
            method:'post',
            data:formData,
          }).then(function (response) {
            if(response.status === 200){
              that.tableData = response.data;
              console.log("mongo",that.tableData)
            }
          })
        },
        handleSizeChange(val) {
          console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
          console.log(`当前页: ${val}`);
        },
        cellClick(row, column, cell, event){ //点击表单时触发时间
          let that = this;
          console.log("row:\n",row,"\n","column:\n",column,"\n","cell:\n",cell,"\n","event:\n",event);
          //Vue.prototype.$Uid =row.Uid; //将全局变量模块挂载到Vue.prototype中
          console.log("选择的cookei是：",row.Uid);
          //that.$router.push({path:'/showMd'}); //不会再新面页打开
          that.setCookie("selectTemp",row.Uid)
          // let formData = new FormData();  //如果需要火箭知道请使用这段代码
          // formData.append("selectNumber",row.Uid);
          // that.axios({
          //   url:"/api/insSelectId",
          //   method:'post',
          //   data:formData,
          // }).then(function (response) {
          //   if(response.status == 200){
          //     console.log("m12收到", row.Uid);
          //     window.open(   that.$router.resolve({path: '/showMd'}).href ,'_blank'  );
          //   }
          // });
          window.open(   that.$router.resolve({path: '/showMd'}).href ,'_blank'  );


        }
      }
    }
</script>

<style scoped>
  *{
    margin: 0;
    padding: 0;
  }
  .mainDiv{
    background-color: #24292e;
    min-height: 100%;
    width: 100%;
    position:absolute;
    top: 0px;
    left: 0px;
  }
.div0{
  color: #ffffff;
  margin-top: 50px;
  margin-bottom: 10%;
  width: 100%;

}
  .div1{
    margin: 0% auto;
    width: 60%;
    padding: 50px 50PX 0 50PX;
    background-color: #ffffff;
    border-radius:10px 10px 0 0;

  }
</style>
